#!/usr/bin/python
# -*- coding: UTF-8 -*-
import random

from kpautos.engine.case import Case
from kptest.config.enum import DeviceType, HostType, DeviceUtility


class NET_CARD_BASIC_TOOL_API_006(Case):
    """
        Name:
            NET_CARD_BASIC_TOOL_API_006
        Label:
            标准工具接口功能测试1
        PreCondition:

        TestStep:
            1) 1、 ethtool工具：ifconfig ethx [-]allmulti
        ExpectedResult:
            A) 在参数正确的情况下，有成功的回显
        Parameters:

        Author:
            XXXXXX
        Last Modified:
            xxxx-xx-xx
        Remark:

    """

    # 测试执行前配置等准备操作
    def pre_test_case(self):
        self.logger.info("Pre Test Case Start.... ")
        self.device_dut = self.resource.get_device(device_type=DeviceType.Server, utility=DeviceUtility.DUT)
        self.os_host = self.device_dut.get_host(host_type=HostType.HostOS)
        self.os_ip = self.os_host.local_ip

    # 测试步骤
    def procedure(self):
        self.log_step("1、ethtool工具：ethtool -i ethx")
        res = self.os_host.run({'command': ['ethtool --version'], 'timeout': 10})[
            "stdout"]
        self.assertIn('eth.tool version', res, f"测试失败，ethtool --version 命令执行结果为：{res}")

    # 测试结束后恢复环境
    def post_test_case(self):
        pass
